/**
 * 版本信息Model页面
 */
import React, { Component } from 'react';
import { Button, message, Table, Modal, Form, Row, Col, Select } from 'antd';
import * as Request from '../../../Server/Upgrade';
import BreadcrumbCustom from '../../BreadcrumbCustom';
import TablePage from '../../TablePage';
import * as Const from '../../../common/const';
import qs from 'qs';
import {AuthButton,AuthA} from '../../auth/OperationAuth';

const confirm = Modal.confirm;
const FormItem = Form.Item;
const Option = Select.Option;
let permissions = undefined;

class DetailTable extends Component{
    constructor(props) {
        super(props);
        permissions = JSON.parse(localStorage.getItem('user')).permission;
        this.state = {
        };
    }

    onChange = (value) =>{
        const { id, pushFunc } = this.props;
        const item = Const.DETAILOPTIONDATA.filter(v=>v.value==value)[0];
        pushFunc(item.url+id);
    }

    render(){
        const { columns, title, addFunc, data, loading, defaultKey, handleTableChange, pagination } = this.props;
        let options = Const.DETAILOPTIONDATA.map((item)=>
                 <Option value={item.value} key={item.value}>
                    {item.title}
                </Option>
        );


        return(
            <div>
                <BreadcrumbCustom first={title} />
                <Row>
                    <Col span={4}>
                        <Select value={defaultKey} style={{ width: '100%', marginTop: 10 }} onChange={this.onChange}>
                            {options}
                        </Select>
                    </Col>
                    <Col span={2} offset={1}>
                        <AuthButton size='large' permission={'version:save'} onClick={()=>addFunc({}, true)}>添加信息</AuthButton>
                    </Col>
                </Row>
                <TablePage
                    dataSource={data}
                    loading={loading}
                    columns={columns}
                    pagination={pagination}
                    onChange={handleTableChange}
                />
            </div>
        )
    }
}

export default DetailTable